package com.dq.controller.api.activity;

import com.dq.exception.customException.AdminException;
import com.dq.vo.Vo;
import com.dq.domain.setup.Advertising;
import com.dq.service.AllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author luchangtong
 * @Date 2019/11/23 17:49
 */
@RestController
@RequestMapping("api/advertising")
@Api(description = "广告位")
public class AdvertisingController extends AllService {

    @ApiOperation("广告位list")
    @GetMapping("adList")
    public Vo adList() throws AdminException{
        return new Vo(advertisingRepository.findByDeletedFalse());
    }

    @ApiOperation("广告位详情")
    @GetMapping("adDetails/{id}")
    public Vo adDetails(@PathVariable Long id) throws AdminException{
        Advertising advertising = dao.get(Advertising.class,id);
        if(advertising == null){
            throw new AdminException("不存在");
        }
        return new Vo(advertising);
    }
}
